/* GUI CONVERTED from soiviq.p (converter v1.75) Wed May 16 22:39:43 2001 */
/* soiviq.p -  INVOICE HISTORY INQUIRY                                  */
/* Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                  */
/* All rights reserved worldwide.  This is an unpublished work.         */
/* $Revision: 1.5.1.3 $                                                     */
/*V8:ConvertMode=Report                                                 */
/* REVISION: 5.0      LAST MODIFIED: 01/15/90   BY: ftb *B511**/
/* REVISION: 6.0      LAST MODIFIED: 04/16/90   BY: ftb *D002**/
/* REVISION: 6.0      LAST MODIFIED: 11/05/90   BY: pml *D178**/
/* REVISION: 7.3      LAST MODIFIED: 11/16/92   BY: afs *G324**/
/* REVISION: 7.3      LAST MODIFIED: 11/19/92   BY: jcd *G339**/
/* REVISION: 7.5      LAST MODIFIED: 03/21/94   BY: gcs *J04C**/
/* REVISION: 7.3      LAST MODIFIED: 10/24/94   BY: smp *GN54**/
/* REVISION: 8.5      LAST MODIFIED: 08/28/95   BY: kxn *J07B**/
/* REVISION: 8.5      LAST MODIFIED: 04/12/96   BY: *J04C* Sue Poland   */
/* REVISION: 8.6      LAST MODIFIED: 10/30/97   BY: mur *K16J**/
/* REVISION: 9.1      LAST MODIFIED: 03/24/00   BY: *N08T* Annasaheb Rahane */
/* REVISION: 9.1      LAST MODIFIED: 08/12/00   BY: *N0KN* myb              */
/* Old ECO marker removed, but no ECO header exists *F0PN*                  */
/* $Revision: 1.5.1.3 $       BY: Falguni             DATE: 05/15/01 ECO: *M17J*    */
/******************************************************************************/
/* All patch markers and commented out code have been removed from the source */
/* code below. For all future modifications to this file, any code which is   */
/* no longer required should be deleted and no in-line patch markers should   */
/* be added.  The ECO marker should only be included in the Revision History. */
/******************************************************************************/


/*GUI preprocessor directive settings */
&SCOPED-DEFINE PP_GUI_CONVERT_MODE REPORT

{mfdtitle.i "b+ "}

define variable inv like ih_inv_nbr.
define variable inv_date like ih_inv_date.
define variable cust like ih_cust.
define variable nbr like ih_nbr.
define variable part like idh_part.
define variable site like idh_site.
define variable po like ih_po.
define variable qty_open like idh_bo_chg.


/*GUI preprocessor Frame A define */
&SCOPED-DEFINE PP_FRAME_NAME A

FORM /*GUI*/ 
   inv           space(.5)   
   po            space(.5)   
   cust          space(.5)   
   part          space(.5)   
   site          space(.5)   
with frame a no-underline width 80 no-attr-space THREE-D /*GUI*/.

/*GUI preprocessor Frame A undefine */
&UNDEFINE PP_FRAME_NAME



/* SET EXTERNAL LABELS */
setFrameLabels(frame a:handle).

{wbrp01.i}

repeat:

   if c-application-mode <> 'web'
   then
      update inv po cust part site with frame a
      editing:

         if frame-field = "inv"
         then do:

            /* FIND NEXT/PREVIOUS RECORD */
            {mfnp.i idh_hist inv idh_inv_nbr inv idh_inv_nbr idh_invln}

            if recno <> ?
            then do:
               inv = idh_inv_nbr.
               display inv with frame a.
               recno = ?.
            end.
         end.
         else do:
            status input.
            readkey.
            apply lastkey.
         end.

      end. /* editing */

   {wbrp06.i
      &command = update
      &fields = "  inv po cust part site"
      &frm = "a"}

   if (c-application-mode <> 'web') or
       (c-application-mode = 'web' and
       (c-web-request begins 'data'))
   then do:
      hide frame b.
      hide frame c.
      hide frame d.
      hide frame e.
      hide frame f.
      hide frame g.
   end.

   /* OUTPUT DESTINATION SELECTION */
   {gpselout.i
       &printType = "terminal"
       &printWidth = 80
       &pagedFlag = " "
       &stream = " "
       &appendToFile = " "
       &streamedOutputToTerminal = " "
       &withBatchOption = "no"
       &displayStatementType = 1
       &withCancelMessage = "yes"
       &pageBottomMargin = 6
       &withEmail = "yes"
       &withWinprint = "yes"
       &defineVariables = "yes"}
       
       {hksimsg.i site site}        /*fdn*/

   if inv <> "" then
      for each ih_hist
         where ih_inv_nbr = inv 
         no-lock,
         each idh_hist
            no-lock
            where idh_inv_nbr = ih_inv_nbr
              and idh_nbr     = ih_nbr
              and (idh_contr_id = po or po = "")
              and (ih_cust = cust or cust = "" )
              and (idh_part = part or part = "")
              and ((idh_site = site AND LOOKUP(idh_site,GLOBAL_user_site) > 0 ) or site = "")
      with frame b width 80 no-attr-space:

         /* SET EXTERNAL LABELS */
         setFrameLabels(frame b:handle).

         
/*GUI*/ {mfguichk.i } /*Replace mfrpchk*/


         qty_open = idh_qty_ord - idh_qty_ship.

         display
            ih_nbr
            idh_line
            idh_part
            idh_site
            idh_qty_inv
            qty_open
            ih_cust WITH STREAM-IO /*GUI*/ .
      end.
   else
   if po <> "" then
      for each ih_hist
         where ih_po = po or ih_sched
         no-lock,
         each idh_hist
         no-lock
         where idh_inv_nbr = ih_inv_nbr
           and idh_nbr     = ih_nbr
           and (ih_cust = cust or cust = "")
           and (idh_part = part or part = "")
           and ((idh_site = site AND LOOKUP(idh_site,GLOBAL_user_site) > 0 ) or site = "")
           and idh_contr_id = po
         by idh_inv_nbr by idh_line
      with frame c width 80 no-attr-space:

         /* SET EXTERNAL LABELS */
         setFrameLabels(frame c:handle).

         
/*GUI*/ {mfguichk.i } /*Replace mfrpchk*/


         qty_open = idh_qty_ord - idh_qty_ship.

         display
            ih_nbr
            ih_inv_nbr
            idh_line
            idh_part
            idh_site
            idh_qty_inv
            qty_open WITH STREAM-IO /*GUI*/ .
      end.

   else
   if cust <> "" then
      loopd:
      for each ih_hist
         no-lock
         where ih_cust = cust,
         each idh_hist
         where idh_inv_nbr = ih_inv_nbr
           and idh_nbr     = ih_nbr
           and (idh_part = part or part = "")
           and ((idh_site = site AND LOOKUP(idh_site,GLOBAL_user_site) > 0 ) or site = "")
         by idh_inv_nbr by idh_line
      with frame d width 80 no-attr-space:

         /* SET EXTERNAL LABELS */
         setFrameLabels(frame d:handle).

         
/*GUI*/ {mfguichk.i } /*Replace mfrpchk*/


         qty_open = idh_qty_ord - idh_qty_ship.

         display
            ih_nbr
            ih_inv_nbr
            idh_line
            idh_part
            idh_site
            idh_qty_inv
            qty_open WITH STREAM-IO /*GUI*/ .
      end.
   else
   if part <> "" then
      for each idh_hist
         where idh_part = part
           and ((idh_site = site AND LOOKUP(idh_site,GLOBAL_user_site) > 0 ) or site = ""),
         each ih_hist
         no-lock
         where ih_inv_nbr = idh_inv_nbr
           and ih_nbr     = idh_nbr
         by idh_inv_nbr by idh_line
      with frame e width 80 no-attr-space:

         /* SET EXTERNAL LABELS */
         setFrameLabels(frame e:handle).

         
/*GUI*/ {mfguichk.i } /*Replace mfrpchk*/


         qty_open = idh_qty_ord - idh_qty_ship.

         display
            idh_inv_nbr
            idh_nbr
            idh_line
            ih_cust
            idh_qty_inv
            qty_open
            ih_inv_date WITH STREAM-IO /*GUI*/ .
      end.
   else
   if site <> "" then
      for each idh_hist
         where ((idh_site = site AND LOOKUP(idh_site,GLOBAL_user_site) > 0 ) or site = "")
         no-lock,
         each ih_hist
         where ih_inv_nbr = idh_inv_nbr
           and ih_nbr     = idh_nbr
         no-lock
         by idh_inv_nbr by idh_line
      with frame g width 80 no-attr-space:

         /* SET EXTERNAL LABELS */
         setFrameLabels(frame g:handle).

         qty_open = idh_qty_ord - idh_qty_ship.

         display
            idh_inv_nbr
            idh_nbr
            idh_line
            ih_cust
            idh_qty_inv
            qty_open
            ih_inv_date WITH STREAM-IO /*GUI*/ .

      end.

   else
      for each ih_hist
         no-lock,
         each idh_hist
         no-lock
         where idh_inv_nbr = ih_inv_nbr
           and idh_nbr     = ih_nbr     AND  LOOKUP(idh_site,GLOBAL_user_site) > 0
         by idh_inv_nbr by idh_line
      with frame f width 80 no-attr-space:

         /* SET EXTERNAL LABELS */
         setFrameLabels(frame f:handle).

         
/*GUI*/ {mfguichk.i } /*Replace mfrpchk*/


         qty_open = idh_qty_ord - idh_qty_ship.

         display
            idh_nbr
            idh_inv_nbr
            idh_line
            idh_part
            idh_site
            idh_qty_inv
            qty_open WITH STREAM-IO /*GUI*/ .
      end.

   {mfreset.i}
/*GUI*/ {mfgrptrm.i} /*Report-to-Window*/


   {pxmsg.i &MSGNUM=8 &ERRORLEVEL=1}
end.       /* repeat */

{wbrp04.i &frame-spec = a}
